package com.yunfeisoft.business.dao.impl.postgres;

import com.applet.base.ServiceDaoImpl;
import com.applet.sql.builder.WhereBuilder;
import com.applet.utils.Page;
import com.yunfeisoft.business.dao.inter.OmsCompanyAddressDao;
import com.yunfeisoft.business.model.OmsCompanyAddress;
import org.springframework.stereotype.Repository;

import java.util.Map;

/**
 * ClassName: OmsCompanyAddressDaoImpl
 * Description: 公司收发货地址表Dao实现
 * Author: Jackie liu
 * Date: 2020-06-02
 */
@Repository
public class OmsCompanyAddressDaoImpl extends ServiceDaoImpl<OmsCompanyAddress, String> implements OmsCompanyAddressDao {

    @Override
    public Page<OmsCompanyAddress> queryPage(Map<String, Object> params) {
        WhereBuilder wb = new WhereBuilder();
        wb.setOrderByWithDesc("createTime");
        if (params != null) {
            initPageParam(wb, params);
            wb.andFullLike("addressName", params.get("addressName"));
        }
        return queryPage(wb);
    }

    @Override
    public int updateSendStatus(String id, int sendStatus) {
        WhereBuilder wb = new WhereBuilder();
        wb.andEquals("id", id);

        OmsCompanyAddress companyAddress = new OmsCompanyAddress();
        companyAddress.setSendStatus(sendStatus);

        return updateByCondition(companyAddress, wb);
    }

    @Override
    public int updateReceiveStatus(String id, int receiveStatus) {
        WhereBuilder wb = new WhereBuilder();
        wb.andEquals("id", id);

        OmsCompanyAddress companyAddress = new OmsCompanyAddress();
        companyAddress.setReceiveStatus(receiveStatus);

        return updateByCondition(companyAddress, wb);
    }
}